<template>
  <div class="outer">
    <div class="name">{{ version.name }}</div>
    <div class="container">
      <div class="list_item gl_mb_5 gl_mt_15">
        <div class="detail fw_600">时长</div>
        <div class="status fw_600">{{ version.validity }} {{ version.validityType.name }}</div>
      </div>
      <div class="list">
        <div v-for="item in modules" :key="item.id" class="list_item">
          <template v-if="item.id in version._editionModules">
            <div class="detail">{{ item.name }}</div>
            <img src="../../../assets/images/hall/checked.png" class="check_icon" alt="">
          </template>
        </div>
      </div>
      <div class="description">
        <div class="gl_py_10">介绍</div>
        <p class="desc_content" :title="version.description">{{ version.description }}</p>
      </div>
      <p class="price_line"><span class="unit">￥</span><span class="price">{{ fenToYuan(version.price, true) }}</span></p>
      <div class="btn" @click="buy()">购买</div>
    </div>
  </div>
</template>

<script>
import { moneyFenToYuan } from '@/lib';
export default {
  props: {
    modules: {
      type: Array,
      default: function() {
        return [];
      }
    },
    version: {
      type: Object,
      default: function() {
        return {};
      }
    }
  },
  data () {
    return {

    };
  },
  methods: {
    buy() {
      this.$parent.buyVersion(this.version);
    },
    fenToYuan (val, ignoreFloat) {
      return moneyFenToYuan(val, ignoreFloat);
    }
  }
};
</script>

<style lang="scss" scoped>
.fw_600 {
  font-weight: 600;
}
.outer {
  width: 286px;
  min-height: 464px;
  font-size: 14px;
  color: #333;
  background: #FFFFFF;
  box-sizing: border-box;
  border-top: 10px solid #06318F;
  border-right: 1px solid #06318F;
  border-bottom: 1px solid #06318F;
  border-left: 1px solid #06318F;
  border-radius: 6px;
}
.name {
  height: 55px;
  line-height: 55px;
  font-weight: 600;
  font-size: 20px;
  text-align: center;
  margin: 0 20px;
  border-bottom: 1px solid #CECECE;
  color: #333333;
  white-space: nowrap;
  overflow: hidden;
}
.container {
  padding: 0 30px;
}
.list {
  min-height: 150px;
}
.list_item {
  line-height: 30px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 14px;
  color: #333;
  .detail {
    flex: 1;
  }
  .check_icon {
    width: 16px;
    height: 16px;
  }
}
.desc_content {
  height: 40px;
  line-height: 20px;
  margin: 0;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.price_line {
  height: 40px;
  text-align: center;
  .unit {
    font-size: 14px;
    margin-right: 5px;
  }
  .price {
    font-size: 36px;
  }
}
.btn {
  width: 165px;
  height: 57px;
  line-height: 57px;
  margin: 15px auto;
  text-align: center;
  cursor: pointer;
  background: #06318F;
  border-radius: 6px;
  font-size: 18px;
  color: #fff;
}
</style>
